package com.oocl.o2o.merchant.controller;

import javax.json.JsonArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.oocl.o2o.merchant.vo.AuditInfo;

@RestController
public class AuditController {
	
	@Autowired
	private WsController wsController;

	@PostMapping("/updateAudit")
	public void notifyAuditInfo(AuditInfo auditInfo) {
		System.out.println(auditInfo);
		ObjectMapper mapper = new ObjectMapper();
		try {
			String content = mapper.writeValueAsString(auditInfo);
			wsController.sendMessage(auditInfo.getUsername(), content);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		
	}
}
